#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/13 9:45
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : addnotice_page.py
# @Project : crm
"""添加公告页面类"""
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from page.base_page import BasePage
from utils.util import HS3
class AddNotice(BasePage):
    url = "{}/crm3/index.php?m=announcement".format(HS3)
    """定义定位器"""
    notice_title_locator = (By.CSS_SELECTOR, 'input[name="title"]')  # 公告标题
    notice_color_locator = (By.CSS_SELECTOR, 'input[name="color"]')  # 公告标题颜色
    notice_content_locator = (By.XPATH, '/html/body')  # 公告内容
    notice_submit_locator = (By.NAME, 'submit')  # 公告保存
    admin_locator = (By.LINK_TEXT,'admin')  # admin编写的
    """具体操作"""
    def notice_title(self,title):
        """输入标题"""
        self.driver.find_element(*self.notice_title_locator).send_keys(title)
    def clear_notice_title(self):
        """删除标题"""
        self.driver.find_element(*self.notice_title_locator).clear()
    def notice_color(self,color):
        """输入颜色编号"""
        self .driver.find_element(*self.notice_color_locator).send_keys(color)
    def ctrl_color(self):
        """全选颜色编号"""
        self .driver.find_element(*self.notice_color_locator).send_keys(Keys.CONTROL,'a')
    def clear_notice_color(self):
        """清除颜色标号"""
        self.driver.find_element(*self.notice_color_locator).clear()
    def notice_content(self,content):
        """输入内容"""
        self.driver.find_element(*self.notice_content_locator).send_keys(content)
    def clear_notice_content(self):
        """清除内容"""
        self.driver.find_element(*self.notice_content_locator).clear()
    def notice_submit(self):
        """保存公告"""
        self.driver.find_element(*self.notice_submit_locator).click()
    def frame_to(self):
        """切换页面到输入内容的那里"""
        self.driver.switch_to.frame(self.driver.find_element_by_class_name('ke-edit-iframe'))
    def parent_to(self):
        """切换页面到最外层"""
        self.driver.switch_to.parent_frame()
    def get_admin_txt(self):
        return self.driver.find_element(*self.admin_locator).text